//
//  CMDBHomeNoticeCell.swift
//  CMDB
//
//  Created by 曹桂祥 on 2017/5/5.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

class CMDBHomeNoticeCell: CustomBaseCell {
    
    var titlelabel    : UILabel!
    var subTitleLabel : UILabel!
    var timeLabe      : UILabel!
    
    override func cellBuildSubViews() {
        
        titlelabel      = UILabel(frame: CGRect(x: 15, y: 15, width: 320, height: 25))
        titlelabel.font = CMDB_13_Bold_FONT
        titlelabel.textColor = word87Color
        contentView.addSubview(titlelabel)
        
        subTitleLabel           = UILabel(frame: CGRect(x: 10, y: 35, width: 320, height: 10))
        subTitleLabel.font      = CMDB_12_FONT
        subTitleLabel.textColor = word54Color
        contentView.addSubview(subTitleLabel)
        
        timeLabe                = UILabel.getInstance()
        timeLabe.textColor      = word54Color
        timeLabe.font           = CMDB_12_FONT
        contentView.addSubview(timeLabe)
        
        timeLabe.snp_makeConstraints { (make) in
            make.top.equalTo(15);
            make.right.equalTo(-15);
        }
        
        let singleView = UIView.CreateLine(CGRect(x: 0, y: 0, width: CMDB_Screen_Width, height: 0.5), lineColor: word12Color)
        
        contentView.addSubview(singleView)
    }
    
    override func loadContent() {
        let noticeData = cellData as! CMDBPublicNoticeBean
        
        // 普通公告
        if noticeData.type == "1" {
            
            titlelabel.text = noticeData.title
            
            subTitleLabel.text = noticeData.content
            
            timeLabe.text = noticeData.createTimeFormat
    
            let size = noticeData.content.suitToSize(CGSize(width: CMDB_Screen_Width - 2 * KleftMargin, height: 999), fontSize: 12, lineSpacing: 2)
            
            subTitleLabel.frame = CGRect(x: KleftMargin, y: 44, width: size.width, height: size.height)
            
            noticeData.cellHeight = CGRectGetMaxY(subTitleLabel.frame) + 15
            
        }else{//敏感用户
            
        }
    }

}
